package com.RMP
{
    import flash.display.*;
    import flash.events.*;
    import com.greensock.*;

    public class AddSubtractIcon extends Sprite
    {
        var fadeSpeed:Number;
        public var inLightbox:Boolean;
        var btn:Sprite;
        var minus:Sprite;
        var plus:Sprite;
        var myRoot:MovieClip;

        public function AddSubtractIcon(param1:MovieClip, param2:Number) : void
        {
            myRoot = param1;
            fadeSpeed = param2;
            btn = new Sprite();
            btn.graphics.beginFill(16777215, 0);
            btn.graphics.drawRect(0, 0, 24, 24);
            btn.graphics.endFill();
            btn.graphics.beginFill(16777215, 1);
            btn.graphics.drawRect(0, 0, 14, 14);
            btn.graphics.endFill();
            btn.buttonMode = true;
            btn.name = "btn";
            btn.addEventListener(MouseEvent.MOUSE_OVER, btnOver);
            btn.addEventListener(MouseEvent.MOUSE_OUT, btnOut);
            btn.addEventListener(MouseEvent.CLICK, btnClick);
            addChild(btn);
            plus = new Sprite();
            plus.graphics.beginFill(7829367, 1);
            plus.graphics.drawRect(4, 0, 2, 4);
            plus.graphics.drawRect(0, 4, 10, 2);
            plus.graphics.drawRect(4, 6, 2, 4);
            plus.graphics.endFill();
            btn.addChild(plus);
            minus = new Sprite();
            minus.graphics.beginFill(7829367, 1);
            minus.graphics.drawRect(0, 4, 10, 2);
            minus.graphics.endFill();
            btn.addChild(minus);
            return;
        }

        function btnOver(event:MouseEvent)
        {
            if (inLightbox == false)
            {
                myRoot.changeToolTipText("Bookmark Image");
                TweenMax.to(plus, fadeSpeed, {alpha:1, tint:myRoot.hotColor, overwrite:true});
            }
            else
            {
                myRoot.changeToolTipText("Remove Bookmark");
                TweenMax.to(minus, fadeSpeed, {alpha:1, tint:myRoot.hotColor, overwrite:true});
            }
            myRoot.showToolTip();
            return;
        }

        function btnOut(event:MouseEvent)
        {
            myRoot.hideToolTip();
            if (inLightbox == false)
            {
                TweenMax.to(plus, fadeSpeed, {alpha:1, tint:myRoot.coldColor, overwrite:true});
            }
            else
            {
                TweenMax.to(minus, fadeSpeed, {alpha:1, tint:myRoot.coldColor, overwrite:true});
            }
            return;
        }

        function btnClick(event:MouseEvent)
        {
            if (inLightbox == false)
            {
                myRoot.changeToolTipText("Remove Bookmark");
                inLightbox = true;
                TweenMax.to(plus, fadeSpeed, {alpha:0, tint:myRoot.coldColor, overwrite:true});
                TweenMax.to(minus, fadeSpeed, {alpha:1, tint:myRoot.hotColor, overwrite:true});
            }
            else
            {
                myRoot.changeToolTipText("Bookmark Image");
                inLightbox = false;
                TweenMax.to(plus, fadeSpeed, {alpha:1, tint:myRoot.hotColor, overwrite:true});
                TweenMax.to(minus, fadeSpeed, {alpha:0, tint:myRoot.coldColor, overwrite:true});
            }
            return;
        }

    }
}
